package com.ruoyi.web.controller.combat.equiplocation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.combat.domain.equiplocation.CombatEquipTask;
import com.ruoyi.combat.service.equiplocation.ICombatEquipTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 网路IP保护任务Controller
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@Api(tags = "课题二：网络IP保护-IP抗定位任务")
@RestController
@RequestMapping("/equip/task")
public class CombatEquipTaskController extends BaseController
{
    @Autowired
    private ICombatEquipTaskService combatEquipTaskService;

    /**
     * 查询网路IP保护任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:task:list')")
    @ApiOperation(value = "查询网路IP保护任务列表")
    @GetMapping("/list")
    public TableDataInfo list(CombatEquipTask combatEquipTask)
    {
        startPage();
        List<CombatEquipTask> list = combatEquipTaskService.selectCombatEquipTaskList(combatEquipTask);
        return getDataTable(list);
    }

    /**
     * 导出网路IP保护任务列表
     */
    @PreAuthorize("@ss.hasPermi('system:task:export')")
    @ApiOperation(value = "导出网路IP保护任务列表")
    @Log(title = "网路IP保护任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatEquipTask combatEquipTask)
    {
        List<CombatEquipTask> list = combatEquipTaskService.selectCombatEquipTaskList(combatEquipTask);
        ExcelUtil<CombatEquipTask> util = new ExcelUtil<CombatEquipTask>(CombatEquipTask.class);
        util.exportExcel(response, list, "网路IP保护任务数据");
    }

    /**
     * 获取网路IP保护任务详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:task:query')")
    @ApiOperation(value = "获取网路IP保护任务详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatEquipTaskService.selectCombatEquipTaskById(id));
    }

    /**
     * 新增网路IP保护任务
     */
    @PreAuthorize("@ss.hasPermi('system:task:add')")
    @Log(title = "网路IP保护任务", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增网路IP保护任务")
    @PostMapping
    public AjaxResult add(@RequestBody CombatEquipTask combatEquipTask)
    {
        return toAjax(combatEquipTaskService.insertCombatEquipTask(combatEquipTask));
    }

    /**
     * 修改网路IP保护任务
     */
    @PreAuthorize("@ss.hasPermi('system:task:edit')")
    @Log(title = "网路IP保护任务", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改网路IP保护任务")
    @PutMapping
    public AjaxResult edit(@RequestBody CombatEquipTask combatEquipTask)
    {
        return toAjax(combatEquipTaskService.updateCombatEquipTask(combatEquipTask));
    }

    /**
     * 删除网路IP保护任务
     */
    @PreAuthorize("@ss.hasPermi('system:task:remove')")
    @Log(title = "网路IP保护任务", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除网路IP保护任务")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatEquipTaskService.deleteCombatEquipTaskByIds(ids));
    }
}
